home *** CD-ROM | disk | FTP | other *** search
- // EditDlg.cpp : implementation file
- // Sven Henze, Tech Soft GmbH 1999
-
- #include "stdafx.h"
- #include "listbox.h"
- #include "EditDlg.h"
- #include "ListboxDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CEditDlg dialog
-
-
- CEditDlg::CEditDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CEditDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CEditDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
-
- m_peParent = pParent;
- m_neID = CEditDlg::IDD;
-
- }
-
-
- void CEditDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CEditDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CEditDlg, CDialog)
- //{{AFX_MSG_MAP(CEditDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CEditDlg message handlers
-
- BOOL CEditDlg::Create()
- {
- return CDialog::Create(m_neID, m_peParent);
-
- } // Create
-
-
- void CEditDlg::CloseDialog()
- {
- ((ListboxDlg*)m_peParent)->EditBoxDone();
- DestroyWindow();
-
- } // DestroyWindow
-
-
- // OK button was pressed
- void CEditDlg::OnOK()
- {
- int cnt, i;
- CListBox* pList;
-
- // get pointer to ListBox window
- if (SingleSelection)
- {
- g_pList = (CListBox*) (m_peParent->GetDlgItem(IDC_LIST2));
- }
- else
- {
- pList = (CListBox*) (m_peParent->GetDlgItem(IDC_LIST1));
- }
-
-
- CEdit* pEdit = (CEdit*) GetDlgItem(IDC_EDIT1); // pointer to edit resource
- CString str;
-
- pEdit->GetWindowText(str); // get text from edit window
-
- if (!str.IsEmpty()) // do not insert/edit NULL strings
- {
- cnt = Getcount(); // number of items in listbox
-
- i=0;
- while (Getsel(i+1)==0)
- {
- i++;
- }
-
- // variable 'j' now contains the selected item. Add the item on this position now !
- pList->DeleteString( i );
- pList->InsertString( i, str );
-
- } // not IsEmpty
-
- CloseDialog();
-
- } // OnOK
-
-
- // Cancel was pressed
- void CEditDlg::OnCancel()
- {
- CloseDialog();
-
- } // OnCancel
-